// Internal defines, don't edit and expect things to work
// -------------------------------------------------------

// for internal sim
// ----------------
#define TURNRATE 90 			// (degrees) how fast we turn per second in degrees at full bank
#define CLIMBRATE_UP 1000 		// (meters * 100) how fast we climb in simulator at 90°
#define CLIMBRATE_DOWN 3000 	// (meters * 100) how fast we climb in simulator at 90°

#define LOITER_RANGE 60 // for calculating power outside of loiter radius

#define TRUE 1
#define FALSE 0
#define ToRad(x) (x*0.01745329252)	// *pi/180
#define ToDeg(x) (x*57.2957795131)	// *180/pi

// GPS baud rates
// --------------
#define NO_GPS		38400
#define NMEA_GPS	38400
#define EM406_GPS	57600
#define UBLOX_GPS	38400
#define ARDU_IMU	38400
#define MTK_GPS		38400
#define SIM_GPS		38400

// GPS type codes - use the names, not the numbers
#define GPS_PROTOCOL_NONE	-1
#define GPS_PROTOCOL_NMEA	0
#define GPS_PROTOCOL_SIRF	1
#define GPS_PROTOCOL_UBLOX	2
#define GPS_PROTOCOL_IMU	3
#define GPS_PROTOCOL_MTK	4
#define GPS_PROTOCOL_HIL	5
#define GPS_PROTOCOL_MTK16	6

// Radio channels
// Note channels are from 0!
#define CH_ROLL 0
#define CH_PITCH 1
#define CH_THROTTLE 2
#define CH_RUDDER 3
#define CH_1 0
#define CH_2 1
#define CH_3 2
#define CH_4 3

#define WP_START_BYTE 0x18		// where in memory home WP is stored + all other WP
#define WP_SIZE 10
#define IR_MAX_FIX .88

// Auto Pilot modes
// ----------------
#define MANUAL 0
#define CIRCLE 1			 // When flying sans GPS, and we loose the radio, just circle
#define STABILIZE 2
#define FLY_BY_WIRE_A 3		// Fly By Wire A has left stick horizontal => desired roll angle, left stick vertical => desired pitch angle, right stick vertical = manual throttle
#define FLY_BY_WIRE_B 4		// Fly By Wire B has left stick horizontal => desired roll angle, left stick vertical => desired pitch angle, right stick vertical => desired airspeed
#define CONFIG 5
#define AUTO 6
#define RTL 7
#define LOITER 8
#define TAKEOFF 9
#define LAND 10

// Events
// ------
#define EVENT_WILL_REACH_WAYPOINT 1
#define EVENT_SET_NEW_WAYPOINT_INDEX 2
#define EVENT_LOADED_WAYPOINT 3
#define EVENT_LOOP 4


//#define BATTERY_VOLTAGE(x) (x*(INPUT_VOLTAGE/1024.0))/0.000294117
//#define BATTERY_VOLTAGE(x) (x*(INPUT_VOLTAGE/1024.0))/0.2941176470588

#define AIRSPEED_PIN 3		//
#define BATTERY_PIN 5		//
#define BLUE_LED_PIN 12		//

#define HOLD_ALT_ABOVE_HOME 8 // bitmask value

//  GCS Message ID's
#define MSG_ACKNOWLEDGE 0x00
#define MSG_HEARTBEAT 0x01
#define MSG_ATTITUDE 0x02
#define MSG_LOCATION 0x03
#define MSG_PRESSURE 0x04
#define MSG_STATUS_TEXT 0x05
#define MSG_PERF_REPORT 0x06
#define MSG_COMMAND 0x22
#define MSG_VALUE 0x32
#define MSG_PID 0x42
#define MSG_TRIMS 0x50
#define MSG_MINS 0x51
#define MSG_MAXS 0x52

//EEPRROM
#define EE_CONFIG 0x00
#define EE_AP_OFFSET 0x01
#define EE_WP_TOTAL 0x09
#define EE_WP_INDEX 0x0A
#define EE_WP_RADIUS 0x0B
#define EE_HOME_ALT 0x0C
#define EE_HOME_LAT 0x0E
#define EE_HOME_LNG 0x12
#define EE_ALT_HOLD_HOME 0x16


// Radio setup
#define EE_RADIO_1 0x200	// all gains stored from here
#define EE_RADIO_2 0x205	// all gains stored from here
#define EE_RADIO_3 0x20A	// all gains stored from here
#define EE_RADIO_4 0x20F	// all gains stored from here
#define EE_ELEVON1_TRIM 0x214
#define EE_ELEVON2_TRIM 0x216
// tuning
#define EE_IR_MAX 0x218
#define EE_AS_TEST 0x21A
#define EE_THR_TEST 0x21C
#define EE_GPS_ENABLED 0x21E
